Component({
  /**
   * 组件的属性列表
   */
  properties: {},

  /**
   * 组件的初始数据
   */
  data: {
    buttons: [{
        id: 1,
        name: '问卷',
        url: '/+paper/pages/questionnaire/questionnaire',
        hide: false
      },
      {
        id: 2,
        name: '管理',
        url: '/+paper/pages/mine/mine',
        hide: true
      }
    ]
  },
  lifetimes: {
    // 生命周期函数，可以为函数，或一个在methods段中定义的方法名
    attached: function() {

    },
  },
  
  /**
   * 组件的方法列表
   */
  methods: {
    go: function (e) {
      wx.navigateTo({
        url: e.currentTarget.dataset.url,
      })
    },
    setButtons: function(data) {
      this.setData({
        buttons: data
      });
    },
    hideButtion:function(id){
      var newbutton = this.data.buttons;
      for (var bu of newbutton) {
        if(bu.id === id){
          bu.hide = true;
        }
      }
      this.setData({
        buttons: newbutton
      });
    },
    showButton:function(id){
      var newbutton = this.data.buttons;
      for (var bu of newbutton) {
        if (bu.id === id) {
          bu.hide = false;
        }
      }
      this.setData({
        buttons: newbutton
      });
    }
  }
});